Started onThursday, 2 September 2021, 2:16 PM
StateFinished
Completed onWednesday, 15 September 2021, 12:20 AM
Time taken12 days 10 hours
Marks6.00/6.00
Grade100.00 out of 100.00

Information

Flag question

Information text

Signal Handling


A signal is a software interrupt delivered to a process. The operating system uses signals to report exceptional situations to an executing program. Some signals report errors such as references to invalid memory addresses; others report asynchronous events.

Read from the following resources:

https://www.gnu.org/software/libc/manual/html_mono/libc.html#Signal-Handling

http://www.csl.mtu.edu/cs4411.ck/www/NOTES/signal/kill.html

Question 1

Correct
Mark 1.00 out of 1.00
Flag question

Question text

Which of the following are Program Error Signals?


Select one or more:

SIGFPE

SIGIO

SIGSYS

SIGIOT

SIGTERM

SIGTRAP

SIGQUIT

SIGINT

SIGWINCH

SIGIGN

SIGSEGV

Question 2

Correct
Mark 1.00 out of 1.00
Flag question

Question text

Which of the following are Termination Signals?

Select one or more:

SIGPOLL

SIGTSTP

SIGTERM

SIGHUP

SIGKILL

SIGQUIT

SIGLOST

SIGINT

SIGABRT

SIGSTOP

Question 3

Correct
Mark 1.00 out of 1.00
Flag question

Question text

Which of the following signals cannot be ignored by a process?

Select one or more:

SIGABRT

SIGSTOP

SIGKILL

SIGTERM

SIGUSR1

Question 4

Correct
Mark 1.00 out of 1.00
Flag question

Question text

Write a function that will setup the current process so that it can handle the following signals:

  • SIGINT
  • SIGQUIT
  • SIGTERM
  • SIGFPE
  • SIGSEGV
  • SIGILL
Your answer must include handler functions for each signal.  Each handler must print, for each signal received, the following line:

Received signal <name>!!!

where <name> is the mnemonic of the signal. 

(penalty regime: 0 %)
// Add handler functions here
void sigint_handler(int sig)
{
printf("Received signal SIGINT!!!");
}
void sigquit_handler(int sig)
{
printf("Received signal SIGQUIT!!!");
}
void sigterm_handler(int sig)
{
printf("Received signal SIGTERM!!!");
}
void sigfpe_handler(int sig)
{
printf("Received signal SIGFPE!!!");
}
void sigsegv_handler(int sig)
{
printf("Received signal SIGSEGV!!!");
 

Feedback

Question 5

Correct
Mark 1.00 out of 1.00
Flag question

Question text

Write two functions with program errors that generate the following signals:

Signal Function prototype
SIGSEGV void generate_SIGFPE()
SIGFPE void generate_SISEGV()

Hint: Avoid using floating-point operations.

(penalty regime: 0 %)
void generate_SIGSEGV() {
raise(SIGSEGV);
}
void generate_SIGFPE() {
raise(SIGFPE);
}

Feedback

Question 6

Correct
Mark 1.00 out of 1.00
Flag question

Question text

Write a function to ignore the signal SIGSEGV using SIG_IGN.

(penalty regime: 0 %)
void ignore_SIGSEGV() {
signal(SIGSEGV, SIG_IGN);
}

Feedback